Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure generated property names for methods named "new" are quoted #55750

Merged
merged 8 commits into from
Sep 15, 2023

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Sep 15, 2023

Fixes #55075
Closes #55109

This effectively replaces #55109, instead using a fix in createPropertyNameNodeForIdentifierOrLiteral instead of the emitter. If you look at the last commit, you'll see that the only change to TS emit was removed, which I believe to be correct as the code was able to be written that way in the first place so should be legal.

While I was here, I made the parameters to createPropertyNameNodeForIdentifierOrLiteral required, which showed that there was an existing bug for this in a code fix. Likely I need a test for this. It also shows that this call doesn't respect stringNamed either, which unfortunately requires some type info I didn't look into getting quite yet.

cc @Andarist

}

// See getNameForSymbolFromNameType for a stringy equivalent
function getPropertyNameNodeForSymbolFromNameType(symbol: Symbol, context: NodeBuilderContext, singleQuote?: boolean, stringNamed?: boolean) {
function getPropertyNameNodeForSymbolFromNameType(symbol: Symbol, context: NodeBuilderContext, singleQuote: boolean, stringNamed: boolean, isMethod: boolean) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idle observation: Lint rule for functions with optional parameters which are never not supplied? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better as some external pass, as ts-eslint doesn't really do stuff cross-project. Technically possible with the new ProjectService thing, maybe.

@jakebailey jakebailey merged commit 9cbcf01 into microsoft:main Sep 15, 2023
19 checks passed
@jakebailey jakebailey deleted the pr-55109-redo branch September 15, 2023 17:25
snovader pushed a commit to mestro-se/TypeScript that referenced this pull request Sep 23, 2023
…icrosoft#55750)

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Backlog Bug PRs that fix a backlog bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Declaration for object with method named "new" incorrectly emitted with construct signature
4 participants